package com.bdq.interaction.infrastructure.persistence.mysql.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bdq.common.enums.CommentTypeEnum;
import com.bdq.common.enums.YesOrNoEnum;
import com.bdq.interaction.infrastructure.persistence.mysql.pojo.InteractionComment;
import com.bdq.interaction.infrastructure.persistence.mysql.mapper.InteractionCommentMapper;
import com.bdq.interaction.infrastructure.persistence.mysql.service.InteractionCommentService;
import org.springframework.stereotype.Service;

/**
* @author malei
* @description 针对表【interaction_comment(交互评论表)】的数据库操作Service实现
* @createDate 2024-05-14 15:04:13
*/
@Service
public class InteractionCommentServiceImpl extends ServiceImpl<InteractionCommentMapper, InteractionComment>
    implements InteractionCommentService {

    @Override
    public IPage<InteractionComment> pageParentComment(Long contentId, Integer pageNo, Integer pageSize) {
        Page<InteractionComment> page = new Page<>();
        page.setCurrent(pageNo);
        page.setSize(pageSize);

        return lambdaQuery()
                .eq(InteractionComment::getContentId, contentId)
                .eq(InteractionComment::getCommentType, CommentTypeEnum.PRIMARY_COMMENT.getCode())
                .eq(InteractionComment::getIsDeleted, YesOrNoEnum.NO.getCode())
                .orderByAsc(InteractionComment::getCreateTime)
                .page(page);
    }

    @Override
    public IPage<InteractionComment> pageChildComment(Long parentCommentId, Integer pageNo, Integer pageSize) {
        Page<InteractionComment> page = new Page<>();
        page.setCurrent(pageNo);
        page.setSize(pageSize);

        return lambdaQuery()
                .eq(InteractionComment::getParentCommentId, parentCommentId)
                .eq(InteractionComment::getIsDeleted, YesOrNoEnum.NO.getCode())
                .orderByAsc(InteractionComment::getCreateTime)
                .page(page);
    }
}




